*	Topic: LAB2 Pt. 13
*	Submitted by : Vishal Verma
*	Date: 2/6/2011
*	Program To generate a sqare wave of 0.5 seconds of ON period and 0.5 seconds of OFF period using timer of 8051.
*	ECEN5613 S2011

			ORG $0000				RESET VECTOR	
			LJMP MAIN
			
			ORG $0100				MAIN PROGRAM
MAIN:
			MOV R4,#0AH
			MOV IE,#%00000010		EA=0   ET0 =1
			MOV IP,#%00000010		T0 INTERRUPT HIGHEST PRIORITY
			MOV PSW,#%00000000		SELECT RES BANK 0
			MOV TMOD,#%00000001		TIMER 0 IN MODE 1
			MOV TCON,#%00000000		TF0 = 0 TR0 =0
			MOV TH0,#4CH			LOAD COUNT HIGHER BYTE
			MOV TL0,#00H			LOAD COUNT LOWER BYTE
			SETB IE.7				GLOBAL INTERRUPT ENABLE
			SETB TCON.4				START TIMER
LOOP:		AJMP LOOP				BLOCK MAIN
			
			ORG $000B				TIMER 0 VECTOR
			SETB P1.6				ISR COUNTER
			LJMP MYISR
			
			ORG $0200				TIME ISR
MYISR:		CLR IE.7				DISABLE INTERRUPTS
			DJNZ R4,NOTDONE			DECREMENT COUNT
			MOV R4,#0AH				RESET COUNT
			CPL P1.7				CHANGE LED STATE

NOTDONE:	MOV TH0,#4CH			TIMER COUNT HIGHER BYTE
			MOV TL0,#00H			TIMER COUNT LOWER BYTE
			SETB IE.7				GLOBAL INTERRUPT ENABLE
			SETB TCON.4				START TIMER
			CLR P1.6				ISR COUNTER
			RETI					RETURN